{extend name="property/public/insidePageBase" /}
{block name="title"}编辑费用{/block}
{block name="body"}
<div class="layuimini-container">
    <div class="layuimini-main">
        <div class="layui-form layui-form-pane">
            <div class="layui-row">
                <div class="layui-col-xs9">
                    <div class="layui-form-item">
                        <label class="layui-form-label">费用类别</label>
                        <div class="layui-input-block">
                            <input type="text" value="{$info['cate_name']??''}" disabled autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-col-xs3" >
                    <button type="button" class="layui-btn layui-btn-normal layui-btn-fluid addBillCate"> 添加费用类别 </button>
                </div>
            </div>
            <div class="layui-row">
                <div class="layui-col-xs6">
                    <div class="layui-form-item layui-input-group">
                        <label class="layui-form-label">费用金额</label>
                        <div class="layui-input-block">
                            <input type="text" name="amount" value="{$info['amount']??''}" autocomplete="off" placeholder="请输入费用金额" class="layui-input" oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')">
                        </div>
                        <div class="layui-input-split layui-input-suffix">¥</div>
                    </div>
                </div>
                <div class="layui-col-xs6" >
                    <div class="layui-form-item layui-input-group">
                        <label class="layui-form-label">支付方式</label>
                        <div class="layui-input-block">
                            <select name="pay_type" {:isset($info['if_bill']) ? $info['if_bill'] != 2 ? 'disabled' : '' : ''}>
                                <option value="">--选择-</option>
                                {foreach $payTypeData as $k=>$v}
                                <option value="{$k}" {:isset($info['pay_type']) ? $info['pay_type'] == $k ? 'selected' : '' : ''}>{$v}</option>
                                {/foreach}
                            </select>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">备注说明</label>
                <div class="layui-input-block">
                    <textarea placeholder="请输入费用说明" class="layui-textarea" name="remark">{$info['remark']??''}</textarea>
                </div>
            </div>
            <div class="layui-form-item layui-hide">
                <button class="layui-btn" lay-submit lay-filter="submitBtn" id="submitBtn">提交</button>
            </div>
        </div>
    </div>
</div>
<script id="bill_cate_data_tpl" type="text/html">
    <input type="text" name="cate_id" id="bill-cate-name" autocomplete="off" class="layui-input">
</script>
{/block}
{block name="js"}
{__block__}
<script>
    layui.use(['form', 'layer', 'laytpl'], function () {
        var form = layui.form,layer = layui.layer,  $ = layui.$,laytpl = layui.laytpl;
        $('.addBillCate').on('click', function() {
            var url = '{:url("propertyBillCateAdd")}';
            var index = parent.layer.open({title: '添加',type: 2,shade: 0.2, maxmin:true,area: ['500px', '450px'], content: url, btnAlign: 'c' , btn: ['确定', '取消'] , yes: function (index, layero) {
                    var iframeWindow = parent.window['layui-layer-iframe' + index] , submit = layero.find('iframe').contents().find("#submitBtn");
                    iframeWindow.layui.form.on('submit(submitBtn)', function (data) {
                        var field = data.field; //获取提交的字段
                        var loadAdd = parent.layer.msg('提交中', {icon: 16, time: 0, shade: 0.1, offset: '15px'});
                        $.post(url, field, function (res) {
                            parent.layer.close(loadAdd);
                            if (res.code === 0) {
                                loadBillCateData()
                                parent.layer.close(index); //关闭弹层
                                parent.layer.msg(res.msg, {icon: 6, offset: '15px'});
                            } else {
                                parent.layer.msg(res.msg, {icon: 5, offset: '15px'});
                            }
                        });
                    });
                    submit.trigger('click');
                }
            });
        });
    });
</script>
{/block}